﻿using System;
using System.Reflection;
using System.Threading.Tasks;

namespace Aquarinum.Base.Infrastructure.EventBus.Interfaces
{
    public interface IEventBus
    {
        /// <summary>
        /// 注册handler
        /// </summary>
        /// <typeparam name="TEventData"></typeparam>
        /// <typeparam name="THandler"></typeparam>
        void Register<TEventData, THandler>() where TEventData : class, IEventData where THandler : IEventHandler;


        ///// <summary>
        ///// 注册程序集内的所有EventHandler
        ///// </summary>
        ///// <param name="assembly"></param>
        //void RegisterAllEventHandlerFromAssembly(Assembly assembly);

        /// <summary>
        /// 卸载handler
        /// </summary>
        /// <param name="handlerType"></param>
        void UnRegister<TEventData>(Type handlerType) where TEventData : class, IEventData;

        /// <summary>
        /// 卸载制定data类型的handler
        /// </summary>
        void UnRegisterAll<TEventData>() where TEventData : class, IEventData;

        /// <summary>
        /// 发布事件
        /// </summary>
        /// <typeparam name="TEventData"></typeparam>
        /// <param name="eventData"></param>
        void Publish<TEventData>(TEventData eventData) where TEventData : class, IEventData;
    }
}